package com.ymatou.apigateway.service;

import org.json.JSONObject;

import com.ymatou.apigateway.parameter.SendLogisticsResult;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.EnvSetup;

public class ShenqiSendLogisticsCall extends YmatouBaseCall {

	private static String opurl = "api/v1?method=sq.order.deliver";

	public ShenqiSendLogisticsCall() {
		super(EnvSetup.getSystemUrl("apigateway"), opurl, "POST", "JSON");
	}

	@Override
	public void addDefHeader() {
		client.addHeader("Accept",
				"text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	public String getCode() {
		return getString("code");
	}

	public String getMessage() {
		return getString("message");
	}

	public String getResults() {
		String Code = null;
		
		try {
			Code = new JSONObject(getString("content")).optString("results");
		} catch (Exception e) {
			e.printStackTrace();
		}

		return Code;
	}

	public SendLogisticsResult getSendLogisticsResult() {
		
		SendLogisticsResult data = null;
		
		try {
			data = (SendLogisticsResult) FormatUtil.GSONToObject(
					getString("content"), SendLogisticsResult.class);

		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return data;
	}
}
